<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>api</title>
<link href="/wondershare/styles/main.css" rel="stylesheet" type="text/css" />
<link href="/wondershare/styles/general.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/wondershare/js/jquery.js"></script> 
<style type="text/css">
#menu div{height:460px;overflow:auto;}
#menu div ul{padding:0px;margin:0px;}
#menu div ul li{padding:2px 10px;list-style:none;cursor:pointer;}
#menu div ul li:hover{background-color:#E7F2F5;}
th a{font-weight:100;}
#manage{display:none;}
.content_left{width:60px; text-align:center;font-weight:bold;}
.content_right{padding-left:10px;}
</style>
<script type="text/javascript">
var api_id;
//note 新增
function loadAdd(){
	$("#content").load('?action=add&type=<{$type}>&r='+Math.random());
}

//note 显示API
function show( tid ){
	$("#content").load('?action=show&tid='+tid+'&r='+Math.random());
	$("#menu li").css('background-color','#FFF');
	$("#li_"+tid).css('background-color','#E7F2F5');
	
	api_id = tid;
	$("#manage").show();
}

//note 编辑
function edit(){
	$("#content").load('?action=edit&tid='+api_id+'&r='+Math.random());	
}

//note 删除
function del(){
	var ret = window.confirm('您确定要删除该接口信息吗？');
	if( !ret ) return;
	$.post('?action=del&r='+Math.random(),{tid:api_id},function(data){
		if( data == 1 ){
			alert('删除成功！');
			window.location.reload();	
		}else{
			alert('删除失败！');
		}
	})
}

//note 选择站点
function selectSite( obj ){
	document.location.href = document.location.href + '&sid='+$(obj).val();
}
</script>
</head>

<body>
<div style="margin:10px;">
<table cellpadding="2" cellspacing="1" width="100%" class="list-div">
	<tr><th width="150">接口列表<{if $isadmin == 1}>
    <select onchange="selectSite(this)">
    <option value="0">所有站点</option>
    <{foreach from=$site_name item=v key=k}>
    <option value="<{$k}>" <{if $k==$sid}>selected="selected"<{/if}>><{$v}></option>
    <{/foreach}>
    </select>
    &nbsp;&nbsp;[<a href="javascript:loadAdd();">新增</a>]<{/if}>
    </th><th>接口内容 <{if $isadmin == 1}><span id="manage">&nbsp;&nbsp;&nbsp;&nbsp;[<a href="javascript:edit();">编辑</a>] &nbsp;&nbsp;[<a href="javascript:del();">删除</a>]</span><{/if}></th></tr>
    <tr>
    	<td valign="top" id="menu"><div><ul><{foreach from=$data item=v}><li id="li_<{$v.tid}>" onclick="show(<{$v.tid}>)"><{$v.name}></li><{/foreach}></ul></div></td>
        <td valign="top" id="content"></td>
   	</tr>
</table>
</div>
</body>
</html>
